import { createRouter, createWebHashHistory } from "vue-router";
import Layout from "@/layout/index.vue";

import menuList from "@/layout/SideBar/menuList";

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: "/",
      component: () => import("../views/account/Login.vue"),
    },
    {
      path: "/login",
      component: () => import("../views/account/Login.vue"),
    },
    {
      path: "/index",
      name: "index",
      component: Layout,
      children: menuList,
    },
  ],
});
// router.beforeEach((to, form, next) => {
//
//   if(to.path === '/login') {
//     next();
//   }else{
//     // 获取token
//     const token = localStorage.getItem('token');
//     if(token) {
//       next("/index");
//     }else{
//       next('/login');
//     }
//   }
// })
export default router;
